//
//  YTKRequestExtension.m
//  YTKNetworkExtension
//
//  Created by Jarvis on 2024/5/28.
//

#import "YTKRequestExtension.h"

@interface YTKRequestExtension ()
@end
@implementation YTKRequestExtension

- (instancetype)init {
    if (self = [super init]) {
        _responseSerializerType = YTKResponseSerializerTypeJSON;
        _allowsCellularAccess = YES;
    }
    return self;
}

- (void)requestCompletePreprocessor {
    !_requestCompletePreprocessorBlock ?: _requestCompletePreprocessorBlock();
}
- (void)requestCompleteFilter {
    !_requestCompleteFilterBlock ?: _requestCompleteFilterBlock();
}
- (void)requestFailedPreprocessor {
    !_requestFailedPreprocessorBlock ?: _requestFailedPreprocessorBlock();
}
- (void)requestFailedFilter {
    !_requestFailedFilterBlock ?: _requestFailedFilterBlock();
}


- (NSTimeInterval)requestTimeoutInterval {
    if (_requestTimeoutInterval > 0) {
        return _requestTimeoutInterval;
    } else {
        return [super requestTimeoutInterval];
    }
}
- (id)cacheFileNameFilterForRequestArgument:(id)argument {
    if (_cacheFileNameFilterForRequestArgumentBlock) {
        return _cacheFileNameFilterForRequestArgumentBlock(argument);
    } else {
        return [super cacheFileNameFilterForRequestArgument:argument];
    }
}

- (YTKRequestMethod)requestMethod {
    return _requestMethod;
}

- (YTKRequestSerializerType)requestSerializerType {
    return _requestSerializerType;
}

- (YTKResponseSerializerType)responseSerializerType {
    return _responseSerializerType;
}

- (BOOL)allowsCellularAccess {
    return _allowsCellularAccess;
}

- (BOOL)statusCodeValidator {
    return [super statusCodeValidator];
}

@end
